<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <button @click='btn1'>点击请求 axios get 无参数 </button>
        </div>
        <div>
            <button @click='btn2'>点击请求 axios get 带参数 </button>
        </div>
        <div>
            <button @click='btn3'>点击请求 axios post 不 带参数 </button>
        </div>
        <div>
            <button @click='btn4'>点击请求 axios post   带参数 </button>
        </div>



        <button @click='btn2'>查看</button>
    </div>


    <script>

        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue22222!',
                city: []
            },
            methods: {
                btn1() {
                    axios({
                        url: 'http://localhost:5003/httpvue',
                        method: 'get'
                    }).then(res => {
                        console.log(res)
                        this.city = res.data.msg
                    })
                },
                btn2() {
                    axios({
                        url: 'http://localhost:5003/httpvue',
                        method: 'get',
                         // post带参数是data  get paramas
                        params: {
                            price: '999',
                            img: 'http:img1',
                            stock: '9999'
                        }
                    }).then(res => {
                        console.log(res)
                    })
                },
                btn3() {
                    axios({
                        url: 'http://localhost:5003/httpvue',
                        method: 'post',
                      
                    }).then(res => {
                        console.log(res)
                    })
                },
                btn4(){
                    axios({
                        url: 'http://localhost:5003/httpvue',
                        method: 'post',
                        // post带参数是data  get paramas
                        data:{
                            name:'zs'
                        }
                    }).then(res => {
                        console.log(res)
                    })
                },
                btn12() {
                    console.log(this.city)
                }
            }
        })

        console.log('app', app)

    </script>
</body>

</html>